package com.ibiz.test.listener;

import org.testng.ITestResult;
import org.testng.TestListenerAdapter;

import com.ibiz.test.util.IActionTest;
import com.ibiz.test.util.IFieldValueTest;
import com.ibiz.test.util.DocXmlUtil;

public class FailureListener extends TestListenerAdapter  {

	@Override
	public void onTestFailure(ITestResult tr) {
		if(tr.getInstance() instanceof IActionTest) {
			IActionTest at = (IActionTest)tr.getInstance();
			try {
				DocXmlUtil.testFailure(at.getTestSn(), DocXmlUtil.RESULT_DEACTION);
			} catch (Exception e) {

			}
		}else if(tr.getInstance() instanceof IFieldValueTest) {
			IFieldValueTest at = (IFieldValueTest)tr.getInstance();
			try {
				DocXmlUtil.testFailure(at.getTestSn(), DocXmlUtil.RESULT_DEFV);
			} catch (Exception e) {

			}
		}
	}

}
